<template>
<el-row>
    <el-row>
    <!--新增/编辑界面 SmsTemplate 短信模板-->
        <el-form :model="editForm"  label-width="120px" :rules="editFormRules" ref="editFormRef">
            
            <el-form-item label="模板名称" prop="title">
                <el-input  v-model="editForm.title" placeholder="模板名称" :maxlength="255" @change="editSomeFields(editForm,'title',$event)" :disabled="  disabledJudge('title')"/>
            </el-form-item>
            <el-form-item label="模板编号" prop="id">
                <el-input  v-model="editForm.id" placeholder="短信模板ID" :maxlength="64" @change="editSomeFields(editForm,'id',$event)" :disabled="  disabledJudge('id')"/>
            </el-form-item>
            <el-form-item label="模板状态" prop="status">
                <mdp-select item-code="sms_tpl_status"  v-model="editForm.status" placeholder="模板状态0表示已通过," :maxlength="1" @change="editSomeFields(editForm,'status',$event)" :disabled="  disabledJudge('status')"/>
            </el-form-item>
            <el-form-item label="短信类型" prop="type">
                <mdp-select item-code="sms_tpl_type"  v-model="editForm.type" placeholder="短信类型，0表示普通短信," :maxlength="1" @change="editSomeFields(editForm,'type',$event)" :disabled="  disabledJudge('type')"/>
            </el-form-item>
            <el-form-item label="国内\国外" prop="international">
                <mdp-select item-code="sms_international" v-model="editForm.international" placeholder="0表示国内短信，1表示国际/港澳台短信，默认为0" :maxlength="1" @change="editSomeFields(editForm,'international',$event)" :disabled="  disabledJudge('international')"/>
            </el-form-item>
            <el-form-item label="短信内容" prop="text">
                <el-input v-model="editForm.text" placeholder="模板示例：{1}为您的登录验证码，请于{2}分钟内填写。如非本人操作，请忽略本短信。 （其中{数字}为可自定义的内容，须从1开始连续编号，如{1}、{2}等）"
					 type="textarea" :rows="5"></el-input>
					<p style="font-size:16px;">1.长度不超过<span style="color:#e54545 ">500字</span>。单条短信超过70字后，按67字/条分多条计费</p>
					<p style="font-size:16px;">2.短信模板内容不能含有【】符号。营销类短信，请在短信内容后面增加“回T退订”</p>
					<p style="font-size:16px;">3.国际短信的海外部分国家运营商，可能会对中文短信内容有过滤（如加拿大/日本等），请尽量使用纯英文短信或当地语种短信</p>
					<p style="font-size:16px;">4.国际短信如果要使用签名，在纯英文短信中请以英文[]替代</p>
					<p style="font-size:16px;">5.禁止发送股票、移民、面试招聘、彩票、返利、抽奖、贷款、催款、投资理财、赌博、中奖、毒品、党政、法律维权、众筹、慈善捐款、宗教、迷信、殡葬、刷单、空包网、一元夺宝、一元秒杀、A
						货、医疗、整形、美容、会所、酒吧、足浴、暴力、恐吓、色情、皮草、助考、商标注册、加群、加 QQ
						或者加微信、贩卖个人信息、宣传短信通道、游戏推广、会展推广、网站推广、优惠券类推广、卡类推广、保险推广、信用卡提额、返现返利、代开发票、邀请好评、酒类、用户拉新以及用户召回等类型的短信
						<a href="https://cloud.tencent.com/document/product/382/13444#.E6.99.AE.E9.80.9A.E7.9F.AD.E4.BF.A1.E5.AE.A1.E6.A0.B8.E6.A0.87.E5.87.86" style="font-size:12px;color:#006eff;" target="_blank">&nbsp;详情&gt;&gt;</a>
					</p>
					<p style="font-size:16px;">
						6.模板示例：{1}为您的登录验证码，请于{2}分钟内填写。如非本人操作，请忽略本短信。 （其中{数字}为可自定义的内容，<span style="color:#e54545 ">须从1开始连续编号</span>，如{1}、{2}等）
					</p>
             </el-form-item>
            <el-form-item label="申请说明" prop="remark">
                <el-input type="textarea" rows="6" v-model="editForm.remark" placeholder="申请说明" :maxlength="255" @change="editSomeFields(editForm,'remark',$event)" :disabled="  disabledJudge('remark')"/>
            </el-form-item>
            
            <el-form-item label="归属机构" prop="branchId">
                <el-input  v-model="editForm.branchId" placeholder="机构ID" :maxlength="64" @change="editSomeFields(editForm,'branchId',$event)" :disabled="  disabledJudge('branchId')"/>
            </el-form-item>
            <el-form-item label="创建时间" prop="createDate">
                <el-date-picker type="date" placeholder="选择日期"  v-model="editForm.createDate"  value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" :disabled="  disabledJudge('createDate')"></el-date-picker>
            </el-form-item>
            <el-form-item label="审批信息" prop="reply">
                <el-input  v-model="editForm.reply" placeholder="审批信息，如果" :maxlength="255" @change="editSomeFields(editForm,'reply',$event)" :disabled="  disabledJudge('reply')"/>
            </el-form-item>
            <el-form-item label="审批时间" prop="replyDate">
                <el-date-picker type="date" placeholder="选择日期"  v-model="editForm.replyDate"  value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" :disabled="  disabledJudge('replyDate')"></el-date-picker>
            </el-form-item>
            <el-form-item label="是否公共" prop="pub">
                <mdp-select item-code="sms_sign_pub" v-model="editForm.pub" placeholder="0-企业私有，1-公共" :maxlength="1" @change="editSomeFields(editForm,'pub',$event)" :disabled="  disabledJudge('pub')"/>
            </el-form-item>
        </el-form>
    </el-row>
    <slot name="footer" :page="this">
        <el-row v-if="showBtn!==false" style="float:right;" class="footer">
            <el-button @click.native="close">关闭</el-button>
            <el-button v-if="currOpType=='add'" v-loading="load.edit" type="primary" @click.native="saveSubmit" :disabled="disabledJudge('addBtn') || !checkBtnQx('addBtn',menuDefId) || load.edit">提交</el-button>
            <el-button v-if="currOpType=='edit'" v-loading="load.edit" type="primary" @click.native="saveSubmit" :disabled="disabledJudge('editBtn') || !checkBtnQx('editBtn',menuDefId) || load.edit">提交</el-button>
        </el-row>
    </slot>
</el-row>
</template>

<script>
import * as SmsTemplateApi from '@/api/mdp/sms/smsTemplate';
import { mapGetters } from 'vuex'
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js';

export default {
    name:'smsTemplateForm',
    mixins:[MdpFormMixin],
    components: {
    },
    computed: {
    },
    props:{
    },
    watch: {
    },
    data() {
        return {
            menuDefId:'',//menu_def.id 菜单表菜单编号，用于按钮权限判断
            pkNames:["id"],//表格主键的java属性名称，驼峰命名，默认为id,支持多主键
            currOpType:'add',//表单 add、edit，所有按钮可动、detail-只看不能操作
            editFormRules: {
                id:[
                //{ required: true, message: '此项必填', trigger: 'change' },
                //{ min: 1,max: 200, message: '长度在1到200之间', trigger: 'change'}
                ]
            },
            editForm: {
                id:'',status:'',type:'',international:'',text:'',title:'',remark:'',shopId:'',locationId:'',branchId:'',createDate:'',reply:'',replyDate:'',pub:''
            },
            //增删改查(含批量)接口
            apis:{
                queryById: SmsTemplateApi.querySmsTemplateById,
                add: SmsTemplateApi.addSmsTemplate,
                edit: SmsTemplateApi.editSmsTemplate,
                editSomeFields: SmsTemplateApi.editSomeFieldsSmsTemplate
            },
            editable:false,//是否可编辑模式
        }
    },
    methods: {
         //由组件扩展添加其它的初始页面的逻辑(mounted+onOpen都会调用此函数，建议只添加公共逻辑)
         initCurrData(){

         },
        /**
         * 检查参数是否满足调用后台接口的条件
         * @returns true / false
         */
        preParamCheck(params){
            return true;
        },
        editSomeFields(row,fieldName,$event,params){ 
            return;
        },
        /**
         * 对修改的字段进行判断，返回false ,将取消更新数据库,由组件扩展
         * @param {*} row 当前选中的行
         * @param {*} fieldName 修改的字段名
         * @param {*} $event 修改后的值
         * @param {*} params 将要提交服务器的参数
         * @returns true/false 返回false ,将取消更新数据库
         */
        editSomeFieldsCheck(row,fieldName,$event,params){
            if(this.editable==false){
                return false;
            }
            params[fieldName]=$event
            return true;
        },
    },
    mounted() {

    }
}

</script>

<style scoped>

</style>